
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
        <meta name="description" content="">
        <meta name="author" content="">

        <title>后台</title>

        <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

        <!-- Bootstrap core CSS -->
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
        <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
    </head>

    <body>

    <include file="Common/topNav" />

    <div class="container-fluid">
        <div class="row">
            <include file="Common/leftMenu" />
            <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                <div class="cont-title clearfix">
                    <div class="title">物业费催缴列表</div>
                    <div class="btn-group">
                    	<button class="btn" type="button" id="add_condo_fee">添加</button>
                        <button class="btn" type="button" id="del_condo_fee">删除</button>
                    </div>
                </div>
                <include file="search" />
                <div class="table-responsive">
                    <table class="table table-striped table-hover" id="tableData">
                        <thead>
                            <tr>
                            	<th>
                            		<input type="checkbox" id="checkAll" />
                            	</th>
                            	<th>序号</th>
                                <th>企业名称</th>
                                <th>所属楼宇</th>
                                <th>企业手机号</th>
                                <th>入驻日期</th>
                                <th>首次缴费日期</th>
                                <th>下次缴费日期</th>
                                <th>缴费周期</th>
                                <th>物管手机号</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <empty name="condoFeeList">
                        	<tr>
                        		<td colspan="10">没有相关记录</td>
                        	</tr>
                        </empty>
                        <foreach name="condoFeeList" item="condoFee">
                            <tr>
                            	<td>
                            		<input type="checkbox" name="condo_fee_check[]" value="{$condoFee.id}" <if condition="$condoFee.status eq 0">disabled</if> />
                            	</td>
                            	<td>{$key|getLineNum=$nowPage,$pageSize}</td>
                                <td>{$condoFee.company_name}</td>
                                <td>{$condoFee.house.name}</td>
                                <td>{$condoFee.contact_phone}</td>
                                <td><if condition="$condoFee['enter_time']">{$condoFee.enter_time|date="Y-m-d",###}</if></td>
                                <td>{$condoFee.first_pay_date|date="Y-m-d",###}</td>
                                <td>{$condoFee.next_pay_date|date="Y-m-d",###}</td>
                                <td>
                                    <switch name="condoFee.pay_cycle">
                                        <case value="0">半年</case>
                                        <case value="1">一年</case>
                                        <case value="2">两年</case>
                                        <case value="3">三年</case>
                                        <default />半年
                                    </switch>
                                </td>
                                <td>{$condoFee.admin_phone}</td>
                            <td>
                                <a thisId="{$condoFee.id}" href="javascript:void(0);" class="condo_fee_edit">修改</a>
                                <if condition="$condoFee['status'] eq '1'">
                                    | <a thisId="{$condoFee.id}" href="javascript:void(0);" class="condo_fee_del">删除</a>
                                </if>
                            </td>
                            </tr>
                        </foreach>    
                        </tbody>
                    </table>
                    <div class="page">
                    	{$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
    

    <include file="Common/modalHtmls" />
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
    <script type="text/javascript">
    	$(function(){
    		$("input[type='checkbox']").iCheck({
    	        checkboxClass: 'icheckbox_flat-blue',
    	        radioClass: 'iradio_flat-blue',
    	        increaseArea: '10%'
    	    });
    		$("#add_condo_fee").bind("click",addCondoFee);
    		$("#del_condo_fee").bind("click",delCondoFeeBatch);
    		$("#tableData .condo_fee_edit").click(function(){
    			editCondoFee(this);
    		});
    		$("#tableData .condo_fee_del").click(function(){
    			delCondoFee(this);
    		});
    		chooseAll();
    	});
    	
    	function chooseAll(){
    		$('#checkAll').on('ifChecked', function(event){
    			$("input[name='condo_fee_check[]']:checkbox").each(function(){
    				var $this = $(this);
        			if(!$this.prop("disabled")){
        				$this.iCheck("check");
        			}
        		});
    		});
    		$('#checkAll').on('ifUnchecked', function(event){
    			$("input[name='condo_fee_check[]']:checkbox").iCheck("uncheck");
    		});
    	}
    	
    	function addCondoFee(){
    		common.loading('正在加载...');
    		common.getHtml("{:U('Admin/CondoFee/add')}", {}, function (html) {
    			common.closeLoading();
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            });
    	}
    	
    	function delCondoFeeBatch(){
    		var str = "";
    		$("input[name='condo_fee_check[]']:checkbox").each(function(){
    			if(true == $(this).is(':checked')){
    				str += "," + $(this).val();
    			}
    		});
    		if(str == ""){
    			common.alert("提示","请至少选择一条记录");
    			return;
    		}
    		common.confirm("提示","确认删除选中的催缴记录吗？",function(){
	    		str = str.substring(1);
	    		var param = {id:str};
	    		$.ajax({
	                url: "{:U('Admin/CondoFee/delete')}",
	                type: "post",
	                dataType: "json",
	                data: param,
	                success: function (data) {
	                    if(data.status){
	                    	common.alert("提示","催缴记录已成功删除!",function(){
	                            common.reload();
	                        });
	                    }
	                }
	            });
    		});
    	}

    	function editCondoFee(obj){
    		var id = $(obj).attr("thisId");
    		common.loading('正在加载...');
    		common.getHtml("{:U('Admin/CondoFee/add')}", {id:id}, function (html) {
    			common.closeLoading();
                $("#commonModal").html(html).modal({show: true, backdrop: 'static', keyboard: false});
            });
    	}
    	
    	function delCondoFee(obj){
    		common.confirm("提示","确认删除该催缴记录吗？",function(){
	    		var id = $(obj).attr("thisId");
	    		var param = {id:id};
	    		$.ajax({
	                url: "{:U('Admin/CondoFee/delete')}",
	                type: "post",
	                dataType: "json",
	                data: param,
	                success: function (data) {
	                    if(data.status){
	                    	common.alert("提示","催缴记录已成功删除!",function(){
	                            common.reload();
	                        });
	                    }
	                }
	            });
    		});
    	}
    	
    </script>
</body>
</html>
